import Point2D from "./Point2D";

export default class Point3D extends Point2D {
    /**
     * @param x {number=}
     * @param y {number=}
     * @param z {number=}
     */
    constructor(x = 0, y = 0, z = 0) {
        super(x, y);
        this.z = z;
    }

    /**
     * @param point3d {Point3D}
     */
    getDistanceFromAnotherPoint(point3d) {
        let modifyAccuracy = 10000000;
        let distance2d = super.getDistanceFromAnotherPoint(point3d);
        return Math.abs(Math.sqrt(Math.pow(distance2d * modifyAccuracy, 2) + Math.pow((this.z - point3d.z) * modifyAccuracy, 2))) / modifyAccuracy;
    }

    /**
     * 获取当前点与另一个点之间的角度
     * @param p {Point3D}
     * @returns {number}
     */
    getDegFromAnotherPoint(p) {
    }


    /**
     * @param surface   {Surface}
     */
    getDistanceFromSurface(surface) {
        if (surface.points.length < 3) {
            return;
        }
        let p = surface.points;
        let vecLine1 = [p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z];
        let vecLine2 = [p[2].x - p[2].x, p[2].y - p[2].y, p[2].z - p[2].z];
        let vecLine3 = [p[2].x - p[0].x, p[2].y - p[0].y, p[2].z - p[0].z];
        // todo later

    }


    /**
     *
     * @param toPoint   {Point3D}
     * @param surface   {Surface}
     */
    isCrossSurfaceToPoint(toPoint, surface) {

    }

}